package com.ruoyi.service.impl;

import com.ruoyi.domain.SpaceCollection;
import com.ruoyi.mapper.SpaceCollectionMapper;
import com.ruoyi.platform.service.impl.BaseServiceImpl;
import com.ruoyi.service.ISpaceCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 智联空间收藏Service业务层处理
 *
 * @author ruoyi
 * @date 2022-12-19
 */
@Service
public class SpaceCollectionServiceImpl extends BaseServiceImpl<SpaceCollectionMapper, SpaceCollection> implements ISpaceCollectionService {

    @Autowired
    private SpaceCollectionMapper spaceCollectionMapper;

    /**
     * 查询智联空间收藏
     *
     * @param id 智联空间收藏主键
     * @return 智联空间收藏
     */
    @Override
    public SpaceCollection selectSpaceCollectionById(Long id) {
        return spaceCollectionMapper.selectSpaceCollectionById(id);
    }

    /**
     * 查询智联空间收藏列表
     *
     * @param spaceCollection 智联空间收藏
     * @return 智联空间收藏
     */
    @Override
    public List<SpaceCollection> selectSpaceCollectionList(SpaceCollection spaceCollection) {
        return spaceCollectionMapper.selectSpaceCollectionList(spaceCollection);
    }

    /**
     * 新增智联空间收藏
     *
     * @param spaceCollection 智联空间收藏
     * @return 结果
     */
    @Transactional
    @Override
    public int insertSpaceCollection(SpaceCollection spaceCollection) {
        return spaceCollectionMapper.insert(spaceCollection);
    }

    /**
     * 修改智联空间收藏
     *
     * @param spaceCollection 智联空间收藏
     * @return 结果
     */
    @Transactional
    @Override
    public int updateSpaceCollection(SpaceCollection spaceCollection) {
        return spaceCollectionMapper.updateById(spaceCollection);
    }

    /**
     * 批量删除智联空间收藏
     *
     * @param ids 需要删除的智联空间收藏主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteSpaceCollectionByIds(Long[] ids) {
        return spaceCollectionMapper.deleteSpaceCollectionByIds(ids);
    }

    /**
     * 删除智联空间收藏信息
     *
     * @param id 智联空间收藏主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteSpaceCollectionById(Long id) {
        return spaceCollectionMapper.deleteSpaceCollectionById(id);
    }

    @Override
    public List<SpaceCollection> getCollectByUserId(String userId, String documentName,Integer page) {
        return spaceCollectionMapper.getCollectByUserId(userId, documentName,page);
    }

    @Override
    public int removeByDocumentIdAndCreateBy(SpaceCollection spaceCollection) {
        return spaceCollectionMapper.deleteByDocumentIdAndCreateBy(spaceCollection.getDocumentId(),spaceCollection.getCreateBy());
    }

    @Override
    public Integer getCollectionTotal(String userId,String documentName) {
        return spaceCollectionMapper.getCollectTotal(userId,documentName);
    }


}
